package com.spider.Test;

import java.util.Random;

public class Demo1 {
    public static String[] poker = new String[54];
    public static void main(String[] args) {
        //设计一个斗地主游戏的做牌和洗牌
        start();
        //洗牌
        shuffle(poker);
    }
    public static void start(){ 

        String[] colors = {"♠","♥","♣","♦"};
        String[] numbers = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
        for (int i = 0; i < numbers.length; i++) {
            for (int i1 = 0; i1 < colors.length; i1++) {
                poker[i*4+i1]=colors[i1]+numbers[i];
            }
        }
        poker[poker.length-1]="BigKing";
        poker[poker.length-2]="SmallKing";
        //打印牌
        System.out.println("原始牌顺序：");
        for (int i = 0; i < poker.length; i++) {
            System.out.print(poker[i]+" ");
        }
        System.out.println();
        System.out.println();
    }
    public static void shuffle(String[] poker){
        //创建一个随机数对象
        Random random = new Random();
        for (int i = 0; i < poker.length; i++) {
            int index = random.nextInt(poker.length);//获取随机索引
            String temp = poker[i];
            poker[i] = poker[index];
            poker[index] = temp;
        }
        //打印牌
        System.out.println("洗牌后的牌顺序：");
        for (int i = 0; i < poker.length; i++) {
            System.out.print(poker[i]+" ");
        }

    }


}
